from socket import *

serverPort = 12000
serverSocket = socket(AF_INET,SOCK_STREAM)

#绑定端口号
serverSocket.bind(('',serverPort))
# 监听 参数为请求监听的最大数
serverSocket.listen(1)
print("The server is ready to receive")

#这下面有点奇怪
while 1:
    #客户来敲门时,创建一个新的套接字connectionSocket,同时创建了一个TCP连接,此时可以互相发送数据
    connectionSocket,addr = serverSocket.accept()

    sentence = connectionSocket.recv(1024).decode(encoding='utf-8')
    capitalizedSentence = sentence.upper()
    connectionSocket.send(capitalizedSentence.encode())
    connectionSocket.close()